package com.turbo.boot.crawler.spider.worker.impl.info;

import com.alibaba.fastjson.JSON;
import com.turbo.boot.crawler.spider.worker.BaseTurboCrawlerPageParser;
import com.xuxueli.crawler.annotation.PageFieldSelect;
import com.xuxueli.crawler.annotation.PageSelect;
import lombok.Getter;
import lombok.Setter;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.springframework.stereotype.Service;

/**
 * 描述
 *
 * @author wuyn
 * @since 2024/4/19
 */
@Service("zjSemCrawlerPageParser")
public class ZjSemCrawlerPageParser extends BaseTurboCrawlerPageParser<ZjSemCrawlerPageParser.PageVo> {

    @Override
    public void parse(Document html, Element pageVoElement, PageVo pageVo) {
        // 解析封装 PageVo 对象
        String pageUrl = html.baseUri();
        System.out.println(pageUrl + "：" + pageVo.toString());
        // 处理业务代码
    }


    @Setter
    @Getter
    @PageSelect(cssQuery = "#div_cbzxjp_pm .redbox")
    public static class PageVo {

        @PageFieldSelect(cssQuery = ".imgtitlebar")
        private String name;

        // 起拍价
        @PageFieldSelect(cssQuery = ".info-section .start")
        private String start;

        // 起拍价
        @PageFieldSelect(cssQuery = ".info-section p:nth-of-type(2) .currency")
        private String appraise;

        // 保证金
        @PageFieldSelect(cssQuery = ".info-section p:nth-of-type(3) .currency")
        private String guarantee;

        @PageFieldSelect(cssQuery = ".info-section .Time_Class")
        private String startTime;

        @Override
        public String toString() {
            return JSON.toJSONString(this);
        }
    }
}
